const { func, object, date } = require('joi')
const db = require('../db/index')

const path = require('path')


// 获取个人信息
exports.get_teacherInfo = function (req, res) {
    // console.log(req.user);
    db.query('select * from teacher where teacher_num=?', req.user.username, function (err, results) {
        if (err) return res.cc(err)
        if (results.length < 1) return res.cc('获取失败')
        res.send({
            status: 0,
            message: '获取成功',
            data: results
        })
    })
}

//确认修改密码
exports.update_teacherPwd = function (req, res) {
    // console.log(req.body);
    // console.log(req.user);
    if (!req.body.old) return res.cc('请输入原密码')
    if (!req.body.pass) return res.cc('请输入新密码')
    db.query('select * from teacher_login where username=?', req.user.username, function (err, result) {
        if (err) return res.cc(err)
        if (result.length < 1) return res.cc('没有找到')
        if (result[0].password != req.body.old) {
            res.cc('原密码错误')
        } else {
            db.query('update teacher_login set ? where username=?', [{ password: req.body.checkPass }, req.user.username], function (err, results) {
                if (err) return res.cc(err)
                if (results.affectedRow < 1) return res.cc('修改失败')
                res.send({
                    status: 0,
                    message: '修改成功'
                })
            })
        }
    })
}

//修改个人信息
exports.update_teacherInfo = function (req, res) {
    if (req.body.phone && req.body.email) {
        db.query('update teacher set ? where teacher_num=?', [{ teacher_phone: req.body.phone, teacher_email: req.body.email }, req.user.username], function (err, results) {
            if (err) return res.cc(err)
            if (results.affectedRow < 1) return res.cc('修改失败')
            res.send({
                status: 0,
                message: '修改成功'
            })
        })
    }
    if (!req.body.phone && req.body.email) {
        db.query('update teacher set ? where teacher_num=?', [{ teacher_email: req.body.email }, req.user.username], function (err, results) {
            if (err) return res.cc(err)
            if (results.affectedRow < 1) return res.cc('修改失败')
            res.send({
                status: 0,
                message: '修改成功'
            })
        })
    }
    if (req.body.phone && !req.body.email) {
        db.query('update teacher set ? where teacher_num=?', [{ teacher_phone: req.body.phone }, req.user.username], function (err, results) {
            if (err) return res.cc(err)
            if (results.affectedRow < 1) return res.cc('修改失败')
            res.send({
                status: 0,
                message: '修改成功'
            })
        })
    }
    if (!req.body.phone && !req.body.email) {
        res.cc('你没有提交的修改信息啊')
    }
}

// 所带学生的信息
exports.getstudentinfo = function (req, res) {
    // console.log(req.user);
    db.query('select studentId from teacher_student where teacherId=?', req.user.username, function (err, results) {
        if (err) return res.cc(err)
        if (results.length < 1) return res.cc('该教师没有带学生')
        // console.log(results);
        const user = []
        for (var i = 0; i < results.length; i++) {
            user.push(results[i].studentId)
        }
        db.query('select * from topic where student_num in (?) and topic_status=1', [user], function (err, resul) {
            if (err) return res.cc(err)
            if (resul.length < 1) return res.cc('没有课题信息')
            const arr = []
            for (var j = 0; j < resul.length; j++) {
                arr.push(resul[j].student_num)
            }
            // console.log(arr);
            db.query('select * from student where student_num in (?) ', [arr], function (err, result) {
                if (err) return res.cc(err)
                if (result.length < 1) return res.cc('没有查到学生信息')
                // console.log(resul);
                // console.log(result);
                res.send({
                    status: 0,
                    message: '所带学生信息查询成功',
                    data: { result, resul }
                })
            })

        })
    })
}

//获取需要通过确认的信息
exports.get_topic = function (req, res) {
    db.query('select *from topic where teacher_id=? and topic_status=0 and student_num is not null', req.user.username, function (err, results) {
        if (err) return res.cc(err)
        if (results.length < 1) return res.cc('没有需要确认的')
        // console.log(results);
        const list = []
        for (var i = 0; i < results.length; i++) {
            list.push(results[i].student_num)
        }
        db.query('select *from student where student_num in (?)', [list], function (err, result) {
            if (err) return res.cc(err)
            if (result.length < 1) return res.cc('没有学生信息')
            res.send({
                status: 0,
                message: '获取需要通过的课题信息',
                data: { results, result }
            })
        })
    })
}

//确认按钮的
exports.update_button = function (req, res) {
    // console.log(req.body.student_num);
    db.query('UPDATE topic  SET topic_status=1 WHERE student_num=?', req.body.student_num, function (err, results) {
        if (err) return res.cc(err)
        if (results.affectedRow < 1) return res.cc('通过失败')
        db.query('insert into teacher_student set ?', { studentId: req.body.student_num, teacherId: req.user.username })
        if (err) return res.cc(err)
        if (results.affectedRow < 1) return res.cc('添加失败')
        res.send({
            status: 0,
            message: '成功'
        })
    })
}

//不通过学生的选题
exports.unpass_choose = function (req, res) {
    db.query('update topic set ? where student_num=?', [{ student_num: null }, req.body.student_num], function (err, results) {
        if (err) return res.cc(err)
        if (results.affectedRow < 1) return res.cc('修改失败'),
            res.send({
                status: 0,
                message: '取消成功'
            })
    })
}

//查看学生信息
exports.get_Allinfo = function (req, res) {
    db.query('select * from student where id=?', req.query.id, function (err, results) {
        if (err) return res.cc(err)
        if (results.length < 1) return res.cc('没有学生信息')
        res.send({
            status: 0,
            message: '看到学生信息了',
            data: results
        })
    })
}

//发放任务书
exports.add_charter = function (req, res) {
    // console.log(req.query);
    // console.log(req.body.student_num);
    // db.query('select * from task where student_num=?', req.body.student_num, function (err, results) {
    //     if (err) return res.cc(err)
    //     if (results.length > 0) return res.cc('已经上传了任务书了')
    // 判断验证req.file
    if (!req.file || req.file.fieldname !== 'file')
        return res.cc('文件必上传')
    //处理文件的信息对象
    const articleInfo = {
        title: req.file.originalname,
        teacher_num: req.user.username,
        student_num: req.query.student_num,
        task: path.join('/upload', req.file.filename)
    }
    // console.log(articleInfo);
    db.query('insert into task set ?', articleInfo, function (err, results) {
        if (err) return res.cc(err)
        if (results.affectedRows != 1) return res.cc('发布失败')
        res.send({
            status: 0,
            message: '发放ok',
            // url: 'http://127.0.0.1:8080/upload/' + req.file.filename + path.parse(req.file.originalname).ext
        })
    })
    // })
}


// 所带学生任务书的信息
exports.getstudentTask = function (req, res) {
    // console.log(req.user);
    db.query('select studentId from teacher_student where teacherId=?', req.user.username, function (err, results) {
        if (err) return res.cc(err)
        if (results.length < 1) return res.cc('该教师没有带学生')
        // console.log(results);
        const user = []
        for (var i = 0; i < results.length; i++) {
            user.push(results[i].studentId)
        }
        db.query('select * from topic where student_num in (?) and topic_status=1', [user], function (err, resul) {
            if (err) return res.cc(err)
            if (resul.length < 1) return res.cc('没有课题信息')
            const arr = []
            for (var j = 0; j < resul.length; j++) {
                arr.push(resul[j].student_num)
            }
            // console.log(arr);
            db.query('select * from student where student_num in (?) ', [arr], function (err, result) {
                if (err) return res.cc(err)
                if (result.length < 1) return res.cc('没有查到学生信息')
                // console.log(resul);
                // console.log(result);
                db.query('select * from task where student_num in (?)', [arr], function (err, resu) {
                    if (err) return res.cc(err)
                    resul.forEach(value => {
                        result.forEach(val => {
                            if (value.student_num === val.student_num)
                                Object.assign(val, { topic_name: value.topic_name });
                        })
                    })

                    result.forEach(val => {
                        resu.forEach(value => {
                            if (value.student_num === val.student_num)
                                Object.assign(val, { title: value.title, task_id: value.id })
                        })
                    })
                    res.send({
                        status: 0,
                        message: '所带学生信息查询成功',
                        data: result,
                    })
                })
            })

        })
    })
}


//获取学生留言
exports.studentmessage = function (req, res) {
    // console.log(req.query);
    db.query('select * from message where student_num=?', req.query.student_num, function (err, results) {
        if (err) return res.cc(err)
        if (results.length < 1) return res.cc('没有学生留言')
        db.query('select* from student where student_num=?', req.query.student_num, function (err, result) {
            if (err) return res.cc(err)
            if (result.length < 1) return res.cc('没有学生信息')
            res.send({
                status: 0,
                message: '学生留言来了',
                data: [results, result]
            })
        })
        // console.log(results);
    })
}

//教师发送留言
exports.post_message = function (req, res) {
    console.log(req.body);
    console.log(req.user);
    console.log(req.query);
    db.query('insert into respondmessage set ?',
        {
            teacher_num: req.user.username,
            resMessage_content: req.body.resMessage_content,
            resMessage_date: new Date(),
            student_num: req.query.student_num
        }, function (err, results) {
            if (err) return res.cc(err)
            if (results.length < 1) res.cc('发送失败')
            res.send({
                status: 0,
                message: '发送成功'
            })
        })
}

//填写指导记录
exports.write_record = function (req, res) {
    // console.log(req.query);
    // console.log(req.user);
    // console.log(req.body);
    db.query('insert into direct set ?',
        {
            direct_date: new Date(),
            direct_from: '教师添加',
            direct_desc: req.body.desc,
            direct_progress: req.body.progress,
            direct_comment: req.body.comment,
            // direct_content: req.body
            student_num: req.query.student_num,
            teacher_num: req.user.username
        }
        , function (err, results) {
            if (err) return res.cc(err)
            if (results.affectedRow < 1) return res.cc('添加失败')
            res.send({
                status: 0,
                message: '添加指导记录成功'
            })
        })

}


//查看提交的课题信息
exports.see_topic = function (req, res) {
    // console.log(req.user);
    db.query('select * from topic where teacher_id=?', req.user.username, function (err, results) {
        if (err) return res.cc(err)
        if (results.length < 1) return res.cc('该教师没有发布课题')
        res.send({
            status: 0,
            message: '教师自己发布的课题来咯',
            data: results
        })
    })
}

//发布课题信息
exports.send_topic = function (req, res) {
    // console.log(req.body);
    db.query('select * from teacher where teacher_num=?', req.user.username, function (err, result) {
        if (err) return res.cc(err)
        if (result.length < 1) res.cc('查询失败')
        // console.log(result);
        const content = {
            teacher_id: req.user.username,
            topic_name: req.body.topic_name,
            topic_from: req.body.topic_from,
            topic_type: req.body.topic_type,
            allow_num: req.body.allow_num,
            topic_degree: req.body.topic_degree,
            topic_work: req.body.topic_work,
            topic_is: req.body.topic_is,
            topic_content: req.body.topic_content,
            paper_requirement: req.body.paper_requirement,
            topic_status: 0,
            pass: 0,
            collage: result[0].teacher_college
        }
        db.query('insert into topic set ?', content, function (err, results) {
            if (err) return res.cc(err)
            if (results.affectedRow < 1) res.cc('添加失败')
            res.send({
                status: 0,
                message: '添加成功'
            })
        })
    })
}

//根据条件获取公告
exports.choose_notice = function (req, res) {
    // console.log(req.body);
    db.query('select * from notice where collage=? and dele_status=0', req.body.region, function (err, results) {
        if (err) return res.cc('错误')
        if (results.length < 1) return res.cc('没有公告')
        // console.log(results);
        res.send({
            status: 0,
            message: '公告来了',
            data: results
        })
    })
}

//获取开题报告
exports.get_report = function (req, res) {
    // console.log(req.user);
    const arr = []
    db.query('select * from teacher_student where teacherId=?', req.user.username, function (err, results) {
        if (err) return res.cc(err)
        if (results.length < 1) return res.cc('没有带学生的呢')
        // console.log(results);
        results.forEach(val => {
            arr.push(val.studentId)
        });
        db.query('select * from student where student_num in (?)', [arr], function (err, resul) {
            if (err) return res.cc(err)
            if (resul.length < 1) return res.cc('没有学生')
            db.query('select * from report where student_num in (?)', [arr], function (err, result) {
                if (err) return res.cc(err)
                if (result.length < 1) return res.cc('同学没有上传开题报告')
                res.send({
                    status: 0,
                    message: '开题报告来了',
                    data: { result, resul }
                })
            })
        })
    })
}

// 开题报告意见
exports.pass_report = function (req, res) {
    db.query('update report set ? where id=?', [{ teacher_idea: req.body.desc, report_status: 1 }, req.body.id], function (err, results) {
        if (err) return res.cc(err)
        if (results.affectedRow < 1) return res.cc('修改失败')
        res.send({
            status: 0,
            message: '成功通过'
        })
    })
}

//获取所带学生的论文
exports.student_paper = function (req, res) {
    db.query('select studentId from teacher_student where teacherId=?', req.user.username, function (err, results) {
        if (err) return res.cc(err)
        if (results.length < 1) return res.cc('没有带学生')
        // console.log(results);
        const arr = []
        results.forEach(val => {
            arr.push(val.studentId)
        })

        db.query('select * from student where student_num in (?)', [arr], function (err, resul) {
            if (err) return res.cc(err)
            if (resul.length < 1) return res.cc('没有学生信息')
            db.query('select * from article where article_dele=0 and article_studentId in (?)', [arr], function (err, result) {
                if (err) return res.cc(err)
                if (result.length < 1) return res.cc('没有论文')
                resul.forEach(val => {
                    result.forEach(value => {
                        if (value.article_studentId == val.student_num)
                            Object.assign(value, { student_name: val.student_name, student_class: val.student_class })
                    })
                })
                res.send({
                    status: 0,
                    message: '获取成功',
                    data: result
                })
            })
        })
    })
    // console.log(arr);
}



//教师评分
exports.teacher_mark = function (req, res) {
    // console.log(req.body);
    db.query('update article set ? where article_dele=0 and article_studentId=? and article_type=?', [{ article_teacherscore: req.body.mark, teacher_observation: req.body.desc }, req.body.article_studentId, req.body.article_type], function (err, results) {
        if (err) return res.cc(err)
        if (results.affectedRow < 1) return res.cc('失败')
        res.send({
            status: 0,
            message: '评分成功'
        })
    })
}

//当评阅教师所分配的学生的获取
exports.look_teacher = function (req, res) {
    const arr = []
    db.query('select * from other_teacher_student where teacher_num=?', req.user.username, function (err, results) {
        if (err) return res.cc(err)
        if (results.length < 1) return res.cc('该教师没有被分配学生')
        // console.log(results);
        results.forEach(val => {
            arr.push(val.student_num)
        })
        // console.log(arr);
        db.query('select * from student where student_num in (?)', [arr], function (err, resul) {
            if (err) return res.cc(err)
            if (resul.length < 1) return res.cc('学生没找到')
            db.query('select * from article where article_type="终稿" and article_dele=0 and article_studentId in (?)', [arr], function (err, result) {
                if (err) return res.cc(err)
                if (result.length < 1) return res.cc('学生没有上传论文')
                // console.log(result);
                result.forEach(value => {
                    resul.forEach(val => {
                        if (value.article_studentId == val.student_num) {
                            Object.assign(value, { student_name: val.student_name })
                        }
                    })
                })
                // console.log(result);
                res.send({
                    status: 0,
                    message: '获取成功',
                    data: result
                })

            })
        })
    })
}

//给分配的学生评分
exports.lookTeacher_mark = function (req, res) {
    // console.log(req.body);
    db.query('update article set ? where article_type="终稿" and article_studentId=?', [{ look_teacherScore: req.body.mark, look_teacherObservation: req.body.desc }, req.body.article_studentId], function (err, results) {
        if (err) return res.cc(err)
        if (results.affectedRow < 1) return res.cc('修改失败')
        res.send({
            status: 0,
            message: '评分成功'
        })
    })
}



//------------------------------------------------------------------------------------

//获取通过教师的开题的学生，并且分给小组长的学生
exports.group_student = function (req, res) {
    db.query('select * from report where report_status=1', function (err, results) {
        if (err) return res.cc(err)
        if (results.length < 1) return res.cc('没有这样的学生')
        const arr = []
        results.forEach(val => {
            arr.push(val.student_num)
        })
        // console.log(arr);
        db.query('select * from teacher where teacher_num=?', req.user.username, function (err, resu) {
            if (err) return res.cc(err)
            if (resu.length < 1) return res.cc('还没有')
            // console.log(resu);
            // console.log(result);
            db.query('select * from teacher_group where group_style="开题答辩小组" and teacher_num=?', req.user.username, function (err, resul) {
                if (err) return res.cc(err)
                if (resul.length < 1) return res.cc('还没有')
                // console.log(resul);
                db.query('select * from student_group where group_style="开题答辩小组" and group_num=? and student_num in (?) and collage=?', [resul[0].group_num, arr, resu[0].teacher_college], function (err, result) {
                    if (err) return res.cc(err)
                    if (result.length < 1) return res.cc('还没有')
                    const arr1 = []
                    result.forEach(val => {
                        if (val.group_num == resul[0].group_num)
                            arr1.push(val.student_num)
                    })
                    db.query('select *  from student where student_num in (?)', [arr1], function (err, re) {
                        if (err) return res.cc(err)
                        if (re.length < 1) return res.cc('还没有')
                        result.forEach(val => {
                            re.forEach(value => {
                                if (val.student_num == value.student_num)
                                    Object.assign(val, { student_name: value.student_name })
                            })
                        })
                        result.forEach(val => {
                            results.forEach(value => {
                                if (val.student_num == value.student_num)
                                    Object.assign(val, { my_report: value.my_report, report_name: value.report_name, reply_status: value.reply_status })
                            })
                        })
                        result.forEach(val => {
                            if (val.reply_status == 0)
                                Object.assign(val, { pass_status: '未通过' })
                            if (val.reply_status == 1)
                                Object.assign(val, { pass_status: '通过' })
                        })
                        res.send({
                            status: 0,
                            message: '来了',
                            data: result
                        })
                    })
                    // console.log(result);
                    // if (resul[0].group_leader == '是') {
                    //     const arr1 = []
                    //     result.forEach(val => {
                    //         if (val.group_num == resul[0].group_num)
                    //             arr1.push(val.student_num)
                    //     })
                    //     db.query('select *  from student where student_num in (?)', [arr1], function (err, re) {
                    //         if (err) return res.cc(err)
                    //         if (re.length < 1) return res.cc('还没有')
                    //         result.forEach(val => {
                    //             re.forEach(value => {
                    //                 if (val.student_num == value.student_num)
                    //                     Object.assign(val, { student_name: value.student_name })
                    //             })
                    //         })
                    //         result.forEach(val => {
                    //             results.forEach(value => {
                    //                 if (val.student_num == value.student_num)
                    //                     Object.assign(val, { my_report: value.my_report, report_name: value.report_name, reply_status: value.reply_status })
                    //             })
                    //         })
                    //         result.forEach(val => {
                    //             if (val.reply_status == 0)
                    //                 Object.assign(val, { pass_status: '未通过' })
                    //             if (val.reply_status == 1)
                    //                 Object.assign(val, { pass_status: '通过' })
                    //         })
                    //         res.send({
                    //             status: 0,
                    //             message: '来了',
                    //             data: result
                    //         })
                    //     })

                    // }
                    // if (resul.group_leader == '否') {
                    //     res.send({
                    //         status: 0,
                    //         message: "你不是组长"
                    //     })
                    // }

                })
            })
        })
    })
}


//小组组长给学生开题报告提交意见
exports.group_idea = function (req, res) {

    db.query('update report set ? where student_num=?', [{ reply_date: new Date(), reply_teacher: req.user.username, reply_idea: req.body.desc, reply_status: 1 }, req.body.student_num], function (err, results) {
        if (err) return res.cc(err)
        if (results.affectedRow < 1) return res.cc('没有找到')
        res.send({
            status: 0,
            message: '提交成功'
        })
    })
}


//获取通过小组组长的开题答辩的学生,，并且分给小组长的学生
exports.graduation_group = function (req, res) {
    db.query('select * from article where article_type="终稿"', function (err, results) {
        if (err) return res.cc(err)
        if (results.length < 1) return res.cc('没有这样的学生')
        // console.log(results);
        const arr = []
        results.forEach(val => {
            arr.push(val.article_studentId)
        })
        // console.log(arr);
        db.query('select * from teacher where teacher_num=?', req.user.username, function (err, resu) {
            if (err) return res.cc(err)
            if (resu.length < 1) return res.cc('没有教师')
            // console.log(resu);
            db.query('select * from student_group where group_style="毕业论文答辩小组" and student_num in (?) and collage=?', [arr, resu[0].teacher_college], function (err, result) {
                if (err) return res.cc(err)
                if (result.length < 1) return res.cc('还没有分配学生')
                // console.log(result);
                db.query('select * from teacher_group where group_style="毕业论文答辩小组" and teacher_num=?', req.user.username, function (err, resul) {
                    if (err) return res.cc(err)
                    if (resul.length < 1) return res.cc('还没有3')
                    // console.log(resul);
                    const arr1 = []
                    result.forEach(val => {
                        if (val.group_num == resul[0].group_num)
                            arr1.push(val.student_num)
                    })
                    db.query('select *  from student where student_num in (?)', [arr1], function (err, re) {
                        if (err) return res.cc(err)
                        if (re.length < 1) return res.cc('还没有4')
                        const arr2 = []
                        results.forEach(val => {
                            re.forEach(value => {
                                if (val.article_studentId == value.student_num)
                                    Object.assign(value, { article_id: val.id, article_name: val.article_name, reply_status: val.reply_status, article_location: val.article_location })
                            })
                        })
                        re.forEach(val => {
                            if (val.reply_status == 0)
                                Object.assign(val, { pass_status: '未通过' })
                            if (val.reply_status == 1)
                                Object.assign(val, { pass_status: '通过' })
                        })
                        res.send({
                            status: 0,
                            message: '来了',
                            data: re
                        })
                    })
                    // if (resul[0].group_leader == '是') {
                    //     const arr1 = []
                    //     result.forEach(val => {
                    //         if (val.group_num == resul[0].group_num)
                    //             arr1.push(val.student_num)
                    //     })
                    //     db.query('select *  from student where student_num in (?)', [arr1], function (err, re) {
                    //         if (err) return res.cc(err)
                    //         if (re.length < 1) return res.cc('还没有4')
                    //         const arr2 = []
                    //         results.forEach(val => {
                    //             re.forEach(value => {
                    //                 if (val.article_studentId == value.student_num)
                    //                     Object.assign(value, { article_id: val.id, article_name: val.article_name, reply_status: val.reply_status, article_location: val.article_location })
                    //             })
                    //         })
                    //         re.forEach(val => {
                    //             if (val.reply_status == 0)
                    //                 Object.assign(val, { pass_status: '未通过' })
                    //             if (val.reply_status == 1)
                    //                 Object.assign(val, { pass_status: '通过' })
                    //         })
                    //         res.send({
                    //             status: 0,
                    //             message: '来了',
                    //             data: re
                    //         })
                    //     })

                    // }
                    // if (resul.group_leader == '否') {
                    //     res.send({
                    //         status: 0,
                    //         message: "你不是组长"
                    //     })
                    // }

                })
            })
        })
    })
}

//小组组长给学生论文打分和给予评语
exports.group_score = function (req, res) {
    // console.log(req.body);
    db.query('update article set ? where article_type="终稿" and article_studentId=?', [{ reply_score: req.body.name, reply_observation: req.body.desc, reply_status: 1 }, req.body.student_num], function (err, results) {
        if (err) return res.cc(err)
        if (results.affectedRow < 1) return res.cc('没有找到')
        res.send({
            status: 0,
            message: '提交成功'
        })
    })
}

//获取当前教师的开题答辩分组情况
exports.group_teacherinfo = function (req, res) {
    db.query('select * from teacher_group where teacher_num=? and group_style="开题答辩小组"', req.user.username, function (err, results) {
        if (err) return res.cc(err)
        if (results.length < 1) return res.cc('该教师没有分配')
        res.send({
            status: 0,
            message: '教师开题答辩信息',
            data: results
        })
    })
}

//获取当前教师的毕业答辩分组情况
exports.group_teacherinfo2 = function (req, res) {
    db.query('select * from teacher_group where teacher_num=? and group_style="毕业论文答辩小组"', req.user.username, function (err, results) {
        if (err) return res.cc(err)
        if (results.length < 1) return res.cc('该教师没有分配')
        res.send({
            status: 0,
            message: '教师开题答辩信息',
            data: results
        })
    })
}


//教师撤回不合格的终稿
exports.noPass = function (req, res) {
    const info = [{
        article_dele: 1
    }, req.body.article_type, req.body.article_studentId]
    db.query('update article set ? where article_type=? and article_studentId=?', info, function (err, results) {
        if (err) return res.cc(err)
        if (results.affectedRow < 1) return res.cc('撤回失败')
        res.send({
            status: 0,
            message: '撤回成功'
        })
    })
}
